#!/usr/bin/env python
# encoding: utf-8
'''
@author: Excelsiorly
@license: (C) Copyright 2021, All Rights Reserved.
@contact: excelsiorly@qq.com
@file: 0002.py.py
@time: 2021/9/7 13:14
@desc:
'''


class Solution:
    def balancedStringSplit(self, s: str) -> int:
        res = 0
        count = 0
        for i in range(len(s)):
            if s[i] == 'R':
                count += 1
            else:
                count -= 1

            if count == 0:
                res += 1

        return res

if __name__ == '__main__':
    sl = Solution()
    s = "RRLRRLRLLLRL"
    count = sl.balancedStringSplit(s)
    print(count)